package 贫困等级;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class MyRecordWriter extends RecordWriter<Text,JavaBean> {
    private BufferedWriter bw;
    public void write(Text key, JavaBean value) throws IOException, InterruptedException {
        String path = "D:\\MP\\贫困等级\\output1\\"+key+".txt";
        bw = new BufferedWriter(new FileWriter(path,true));
        bw.write(value.toString());
        bw.write("\n");
        bw.flush();
    }

    public void close(TaskAttemptContext context) throws IOException, InterruptedException {
        bw.close();
    }
}
